package com.lagou.goods.controller;

import com.lagou.common.pojo.Goods;
import com.lagou.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @GetMapping("/query/{id}")
    public Goods queryById(@PathVariable Integer id){
        return goodsService.queryById(id);
    }

    @RequestMapping(value="/update",method= RequestMethod.POST)
    @ResponseBody
    public int updateById(@RequestBody Goods goods){
        return goodsService.updateById(goods);
    }

    @GetMapping("delete/{id}")
    public int deleteById(@PathVariable Integer id){
        return goodsService.deleteById(id);
    }

    @GetMapping("queryAll")
    public List<Goods> queryAll(){
        return goodsService.queryAll();
    }
}
